﻿using System;

public class Circle
{
    private double radius;
    private const double PI = 3.141592653589793;
    public Circle(double radius)
    {
        this.radius = radius;
    }
    public double Radius
    {
        get { return radius; }
        set
        {
            radius = value;
        }
    }

    public double CalculateCircumference()
    {
        return 2 * PI * radius;
    }

    public double CalculateArea()
    {
        return PI * radius * radius;
    }
    public void DisplayInfo()
    {
        Console.WriteLine("===== 圆的信息 =====");
        Console.WriteLine($"半径: {radius}");
        Console.WriteLine($"周长: {CalculateCircumference():F4}");
        Console.WriteLine($"面积: {CalculateArea():F4}");
        Console.WriteLine("====================");
    }


}

class Program
{
    static void Main(string[] args)
    {

        // 使用有参构造函数创建圆
        Circle circle2 = new Circle(5.0);
        Console.WriteLine("\n使用半径5.0创建的圆:");
        circle2.DisplayInfo();



        Console.WriteLine("\n用户输入测试:");
        Console.Write("请输入圆的半径: ");
        try
        {
            double userRadius = Convert.ToDouble(Console.ReadLine());
            Circle userCircle = new Circle(userRadius);
            userCircle.DisplayInfo();
        }
        catch (FormatException)
        {
            Console.WriteLine("输入格式错误，请输入有效的数字");
        }
        catch (ArgumentException ex)
        {
            Console.WriteLine($"输入错误: {ex.Message}");
        }

        Console.WriteLine("\n测试完成，按任意键退出...");
        Console.ReadKey();
    }
}